from pynput.mouse import Listener

def on_click(x, y, button, pressed):
    if not pressed:
        with open('b.txt', 'a') as file:
            file.write(f"{x}, {y}\n")

with Listener(on_click=on_click) as listener:
    listener.join()